package com.lucene.controller;

import com.log.ws.LoggerMessage;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by zhangzhen on 20/10/2017.
 */
@Controller
public class IndexController {
    private static Logger logger = Logger.getLogger(IndexController.class);

//    @Autowired
//    public SimpMessagingTemplate template;

    @RequestMapping(value = "/",method = RequestMethod.GET)
    public ModelAndView index() {
        return new ModelAndView("index");
    }

//    @RequestMapping(value = "/wlogin",method = RequestMethod.GET)
//    public ModelAndView wlogin() {
//        return new ModelAndView("wlogin");
//    }
//
//    @MessageMapping("/send")
//    @SendTo("/topic/send")
//    public LoggerMessage send(LoggerMessage message) throws Exception {
//        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        message.setTimestamp(df.format(new Date()));
//        return message;
//    }
//
//    @Scheduled(fixedRate = 1000)
//    @SendTo("/topic/callback")
//    public Object callback() throws Exception {
//        // 发现消息
//        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        template.convertAndSend("/topic/callback", df.format(new Date()));
//        return "callback";
//    }
}
